//
//  MyAccountModel.swift
//  DollBuy
//
//  Created by 郑东喜 on 2016/12/6.
//  Copyright © 2016年 郑东喜. All rights reserved.
//

import UIKit

class MyAccountModel: NSObject {
    
    static let shared = MyAccountModel()
    
    var accountArray = NSMutableArray()

    //将登陆状态传给闭包
    
    //外部闭包变量
    var comfun:((_ _data:String)->Void)?
    
    /**
     ## 登陆
     主要实现了登陆封装逻辑
     
     - tfNum    电话号码
     - tfPass   密码
     */
    func getAccout(_com:@escaping (_ _data:String)->Void) -> Void {
        

        accountArray = [["b": "456", "a": "123", "c": "2010-10-09"], ["b": "456", "a": "123", "c": "2010-10-09"], ["b": "456", "a": "123", "c": "2010-10-09"]]
        
        comfun = _com
        
        print("\((#file as NSString).lastPathComponent):(\(#line)):(\("单机登陆")))")
        
        guard let token = localSave.object(forKey: userToken) as? String else {
            return
        }

            //请求参数
            let params = ["token": token]

            print(params)
            
            //提示栏

            postWithPath(path: integrallogURL, paras: params, success: { (response) in
                
                //判读返回值是否为空
                guard let dic = response as? NSDictionary else {
                    return
                }
                
                
//                print(dic["list"])
                
                //提取提示语
                let alertmsg = dic["resultmsg"] as! String

                //传值
                self.comfun!(alertmsg)
                
                
            }, failure: { (error) in
                print("\((#file as NSString).lastPathComponent):(\(#line))")
                print(error)
                
        
            })
            

            
        
    }
}
